﻿#include "mylabel.h"
#include <QDebug>
#include <QEvent>

myLabel::myLabel(QWidget *parent)
    : QLabel{parent}
{}

void myLabel::enterEvent(QEnterEvent *event)
{
    //qDebug()<<"enterEvent";
}

void myLabel::leaveEvent(QEvent *event)
{
    //qDebug()<<"leaveEvent";
}

void myLabel::mousePressEvent(QMouseEvent *ev)
{
    //ev->button();
    //QString str=QString("posx=%1,posy=%2").arg(ev->x()).arg(ev->y());
    qDebug()<<"mousePressEvent";
}

void myLabel::mouseReleaseEvent(QMouseEvent *ev)
{
    qDebug()<<"mouseReleaseEvent";
}

void myLabel::mouseMoveEvent(QMouseEvent *ev)
{
    qDebug()<<"mouseMoveEvent";
}

bool myLabel::event(QEvent *e)
{
    if(e->type()==QEvent::MouseButtonPress)
    {
        qDebug()<<"mousePressEvent1111";

        // 代表用户自己处理这个事件，不向下发送
        return true;
    }
    // 其他交给父类处理
    return QLabel::event(e);
}
